package com.yuuzy.context;

/**
 * 存入线程的公共类
 */
public class BaseContext {
    //用于保存用户id
    public static ThreadLocal<Integer> threadLocal1 = new ThreadLocal<>();
    //用于保存用户名
    public static ThreadLocal<String> threadLocal2 = new ThreadLocal<>();
    //用于保存用户身份
    public static ThreadLocal<Integer> threadLocal3 = new ThreadLocal<>();


    public static void setCurrentId(Integer id) {
        threadLocal1.set(id);
    }

    public static Integer getCurrentId() {
        return threadLocal1.get();
    }

    public static void removeCurrentId() {
        threadLocal1.remove();
    }

    public static void setCurrentUsername(String username) {
        threadLocal2.set(username);
    }

    public static String getCurrentUsername() {
        return threadLocal2.get();
    }

    public static void removeCurrentUsername() {
        threadLocal2.remove();
    }

    public static void setCurrentRole(Integer role) {
        threadLocal3.set(role);
    }

    public static Integer getCurrentRole() {
        return threadLocal3.get();
    }

    public static void removeCurrentRole() {
        threadLocal3.remove();
    }
}
